#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
    int T;
    scanf("%d", &T);
    while (T--)
    {
        int n = 0, i = 0, j = 0, count = 0;
        scanf("%d", &n);
        for (i = n; i > 0; i--)
            for (j = i; j > 0; j /= 10)
            {
                count++;
            }
        printf("%d\n", count);
    }
    return 0;
}

